<template>
  <div>
    <el-table :data="list" highlight-current-row>
      <el-table-column label="结论" align="center" prop="result" />
      <el-table-column
        label="指导意见"
        align="center"
        prop="guidingOpinion"
        show-overflow-tooltip
      />
      <el-table-column label="操作" align="center">
        <template slot-scope="scope">
          <el-button type="text" size="small" @click="handleUpdate(scope.row)"
            >编辑</el-button
          >
          <el-button type="text" size="small" @click="handleDelete(scope.row)"
            >删除</el-button
          >
        </template>
      </el-table-column>
    </el-table>
    <!-- 指导意见对话框 -->
    <el-dialog
      :title="title"
      :visible.sync="open"
      width="600px"
      append-to-body
      :close-on-click-modal="false"
    >
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="结论" prop="result">
          <el-input
            v-model="form.result"
            placeholder="请输入检查项目"
            type="textarea"
            :rows="4"
            :autosize="{ minRows: 4, maxRows: 8 }"
            show-word-limit
            maxlength="200"
            clearable
          />
        </el-form-item>
        <el-form-item label="医学解释" prop="result">
          <el-input
            v-model="form.result"
            placeholder="请输入医学解释"
            type="textarea"
            :rows="4"
            :autosize="{ minRows: 4, maxRows: 8 }"
            show-word-limit
            maxlength="200"
            clearable
          />
        </el-form-item>
        <el-form-item label="常见原因" prop="result">
          <el-input
            v-model="form.result"
            placeholder="请输入检查项目"
            type="textarea"
            :rows="4"
            :autosize="{ minRows: 4, maxRows: 8 }"
            show-word-limit
            maxlength="200"
            clearable
          />
        </el-form-item>
        <el-form-item label="指导意见" prop="result">
          <el-input
            v-model="form.result"
            placeholder="请输入检查项目"
            type="textarea"
            :rows="4"
            :autosize="{ minRows: 4, maxRows: 8 }"
            show-word-limit
            maxlength="200"
            clearable
          />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确定</el-button>
        <el-button @click="cancel">取消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
export default {
  name: "TableData",
  data() {
    return {
      // 遮罩层
      loading: false,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        skipCount: 0,
        maxResultCount: 10,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {},
      // 表格列表
      list: [
        {
          id: "1",
          result: "mei",
          guidingOpinion: "没意见 ",
        },
        {
          id: "1",
          result: "mei",
          guidingOpinion: "没意见 ",
        },
      ],
    };
  },
  computed: {},
  methods: {
    /** 查询列表 */
    getList() {
      this.loading = true;
      // listProject(this.queryParams).then((response) => {
      //   this.projectList = response.rows
      //   this.total = response.total
      //   this.loading = false
      // })
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: undefined,
        result: undefined,
      };
      this.resetForm("form");
    },
    /** 编辑按钮操作 */
    handleUpdate(row) {
      this.reset();
      this.open = true;
      this.title = row.result;
      // const id = row.id || this.ids
      // getProject(id).then((response) => {
      //   this.form = response.data
      //   this.open = true
      //   this.title = '编辑'
      // })
    },
    // 提交按钮
    submitForm() {
      // this.$refs['form'].validate((valid) => {
      //   if (valid) {
      //     if (this.form.id != null) {
      //       updateProject(this.form).then((response) => {
      //         this.$modal.msgSuccess('编辑成功')
      //         this.open = false
      //         this.getList()
      //       })
      //     } else {
      //       addProject(this.form).then((response) => {
      //         this.$modal.msgSuccess('新增成功')
      //         this.open = false
      //         this.getList()
      //       })
      //     }
      //   }
      // })
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal
        .confirm("是否确认删除？")
        .then(function () {
          // return delProject(ids);
        })
        .then(() => {
          this.getList();
          this.$modal.msgSuccess("删除成功");
        })
        .catch(() => {});
    },
  },
};
</script>

<style>
</style>
